$(function () {
    showInfo()
    $(".button-xc").click(function () {
        let qe = confirm("确定添加发放订单？");
        if (qe == false) {
            return
        }

        $.ajaxSettings.async = false;
        $.post("/xc/add", function (data) {
            if (data > 0) {
                alert("添加成功！")
                showInfo()
            } else {
                alert("添加失败！")
            }
        })
        $.ajaxSettings.async = true;
    });

})

function showInfo() {
    $(".table-xc").html("<tr><td>序号</td><td>薪酬单编号</td><td>总人数</td><td>基本薪酬总额</td><td>实发金额</td><td>发放时间</td><td>操作</td></tr>")
    $.ajaxSettings.async = false;
    $.getJSON("/xc/sel", function (data) {
        console.log(data)
        $(data).each(function (i,v) {
            let tim ;
           if (v.time==null){
               tim= "未发放";
           }else {
               tim = v.time;
           }

            let show = "<tr>"+
                "<td>"+(i+1)+"</td>"+
                "<td>"+v.coder+"</td>"+
                "<td>"+v.count+"</td>"+
                "<td>"+v.total+"</td>"+
                "<td>"+v.netPayroll+"</td>"+
                "<td>"+tim+"</td>"+
                "<td>"+
                "<div class='layui-btn-container'>"+
                "<input type='button' class='layui-btn layui-btn-sm button-xq' onclick='details1("+v.id+")' value=' 详情 '/>"+
                // "<input type='button' class='layui-btn layui-btn-sm button-xq' value='v.id'>"+"详情"+"</input>"+
                "</div>"+"</td>"+
                "</tr>"
            $(".table-xc").append(show)
        })

    })
    $.ajaxSettings.async = true;

}
function details1(thisA){
    window.location.href="/xc/detail/"+thisA;
}
// $(".button-xq").click(function () {
//     let id = this.id
//     window.location.href="/xc/detail/"+id;
// })
// function tijiao() {
//
//     let qe = confirm("确定添加发放订单？");
//     if (qe==false){
//         return
//     }
//
//     $.ajaxSettings.async = false;
//     $.post("/xc/add",function (data) {
//         if (data>0){
//             alert("添加成功！")
//         }else {
//             alert("添加失败！")
//         }
//     })
//
// }